<template>
  <div class="app-container">
    <div style="float: right">
      <el-row :gutter="10" class="mb8">
        <el-col :span="1.5">
          <el-button
            type="primary"
            plain
            size="mini"
            @click="achieve"
             :disabled="operate"
            v-hasPermi="['departure:financial:finishGrad']" v-if="activeTab == 0 ? true: false"
            >完成离校</el-button
          >
        </el-col>
        <el-col :span="1.5">
          <el-button
            type="primary"
            plain
            size="mini"
            @click="amend"
            v-hasPermi="['departure:financial:exportYxz']" v-if="activeTab == 2 ? true: false"
            >变更无问题银行卡</el-button
          >
        </el-col>
        <el-col :span="1.5">
          <el-button
            type="primary"
            plain
            size="mini"
            @click="handleExport"
            v-hasPermi="['departure:financial:export']"
            >导出数据</el-button
          >
        </el-col>
      </el-row>
    </div>

    <el-table :data="blackList">
      <el-table-column
        label="学院专业班级"
        align="center"
        prop="dsc"
        show-overflow-tooltip
      >
      </el-table-column>
      <el-table-column label="注册号" align="center" prop="regCode">
      </el-table-column>
      <el-table-column label="学生姓名" align="center" prop="studentName">
      </el-table-column>

      <el-table-column label="学位" align="center" prop="edLevel" width="60">
      </el-table-column>
      <el-table-column
        label="毕业生状态"
        align="center"
        prop="gdpStatus"
        width="100"
      >
        <template slot-scope="scope">
          <dict-tag
            :options="dict.type.dep_grad_status"
            :value="scope.row.gdpStatus"
          />
        </template>
      </el-table-column>
      <el-table-column label="收费" align="center" prop="sf">
      </el-table-column>
      <el-table-column label="押金" align="center" prop="yj">
      </el-table-column>
      <el-table-column label="书费退费" align="center" prop="rfSfAmount">
      </el-table-column>
      <el-table-column label="宿舍赔偿费" align="center" prop="rfSsAmount">
      </el-table-column>
      <el-table-column label="饭卡退费" align="center" prop="rfFkAmount">
      </el-table-column>
      <el-table-column label="图书馆赔偿费" align="center" prop="rfTsgAmount">
      </el-table-column>
      <el-table-column label="水电费退费" align="center" prop="rfSdAmount">
      </el-table-column>
      <el-table-column label="合计" align="center" prop="rfSumAmount">
      </el-table-column>
      <el-table-column label="操作" align="center" width="60">
        <template slot-scope="scope">
          <el-button size="mini" type="text" @click="handleEdit(scope.row)"
            >详情</el-button
          >
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>
<script>
import {finishGrad,confirmTime} from '@/api/departure/financing'
import moment from "moment";
export default {
  name: "Dict",
  dicts: ["dep_grad_scope", "dep_grad_status"],
  props: {
    backList: {
      type: Array, // 根据实际数据类型来定义
      default: null,
      require: true,
    },
    activeTab: {
      type: String,
      default: null,
      require: true,
    },
    queryParams: {
      type: Object,
      default: null,
      require: true,
    },
    
  },
  data() {
    return {
      // 字典表格数据
      blackList: [],
      operate:true
    };
  },

  mounted() {
    // console.log(this.backList,this.queryParams, "zujian");
    // console.log(this.queryParams, "12315464");
    this.blackList = this.backList;
    this.getTitme(this.queryParams.dgsId)
  },
  methods: {
    getTitme(data) {
      if(data){
        confirmTime(this.queryParams.dgsId).then((res) => {
      console.log(res, "时间");
      if (res.code == 200) {
        // const startTime = moment(res.data.startTime, 'YYYY年MM月DD日').format('YYYY-MM-DD')
        // const endTime = moment(res.data.endTime, 'YYYY年MM月DD日').format('YYYY-MM-DD')
        // const now = new Date();
        // const year = now.getFullYear();
        // const month = (now.getMonth() + 1).toString().padStart(2, "0");
        // const day = now.getDate().toString().padStart(2, "0");
        // const dataDay = year + "-" + month + "-" + day;
        if (
          new Date().getTime() > new Date(res.data.endTime).getTime()
        ) {
          this.operate = false;
        } else {
          this.operate = true;
        }
      } else {
        this.operate = true;
      }
    });
      }
    },
    achieve() {
      let dgsId =this.queryParams
      this.$modal
        .confirm('温馨提示：点击确认离校后，学生点击确认离校后，且银行卡号无误的学生才能离校状态同步给收费系统。')
        .then(function () {
          return finishGrad(dgsId)
        })
        .then(() => {
          this.$emit('child-event');
          this.$modal.msgSuccess("离校完成");
        })
        .catch(() => {});

     
    },
    handleEdit(row) {
      this.$router.push({
        path: "/departure/gradStuRoster/departureDetails",
        query: { dgsrId: row.dgsrId },
      });
    },
    handleExport() {
      this.download(
        "/departure/financial/export",
       {... this.queryParams},
        `财务离校_${new Date().getTime()}.xlsx`
      );
    },
    amend() {
      this.download(
        "/departure/financial/eddYxz",
       {... this.queryParams},
        `已修正学生银行卡_${new Date().getTime()}.xlsx`
      );
    }
  },
};
</script>